// Learn more about Tauri commands at https://tauri.app/v1/guides/features/command
mod event;
mod setup;

use setup::{app_listen, webview_listen};

#[tauri::command]
fn open_file(invoke_message: &str) -> Result<String, String> {
    println!("Hello, {}! You've been greeted from Rust!", invoke_message);
    Ok("Hello, {}! You've been greeted from Rust!".to_string())
}

#[cfg_attr(mobile, tauri::mobile_entry_point)]
pub fn run() {
    tauri::Builder::default()
        .plugin(tauri_plugin_fs::init())
        .plugin(tauri_plugin_dialog::init())
        .plugin(tauri_plugin_shell::init())
        .invoke_handler(tauri::generate_handler![open_file])
        .setup(|app: &mut tauri::App| {
            app_listen(app);
            webview_listen(app);
            Ok(())
        })
        .run(tauri::generate_context!())
        .expect("error while running tauri application");
}
